{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Person(name='gengxuelong', age=22)\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "# 实际测试dataclass的用法\n",
    "from dataclasses import dataclass\n",
    "@dataclass()\n",
    "class Person:\n",
    "    name: str\n",
    "    age: int\n",
    "\n",
    "person = Person('gengxuelong',21)\n",
    "person1 = Person('gengxuelong',21)\n",
    "print(person)\n",
    "print(person==person1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[27384, 46729, 53901, 11, 37046, 21043, 20551, 123, 25132, 103, 84012, 247, 0]\n",
      "雪\n"
     ]
    }
   ],
   "source": [
    "import tiktoken\n",
    "enc = tiktoken.get_encoding('cl100k_base') # gpt4使用的分词规则, 其可能使用两个数字代表一个汉字\n",
    "word = \"大家好,我是耿雪龙!\"\n",
    "tokens = enc.encode(word)\n",
    "print(tokens)\n",
    "text = enc.decode(tokens)\n",
    "print(text)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('hh', 'nn', 'ss')\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "tuples = tuple(['hh','nn','ss'])\n",
    "print(tuples)\n",
    "print(tuples.index('nn'))"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n"
     ]
    }
   ],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
